<?php

class LOLAction extends AdminbaseAction{

	public $lol;

	public function _initialize(){

		parent::_initialize();

		$this->lol = new Model('LOL');
	}

	public function index(){
		echo 1;
	}

	/**
	 * 管理成员
	 * @return [type] [description]
	 */
	public function manage(){

		$list = M('lol')->select();

		$this->assign('list',$list);

		$this->display();
	}

	/**
	 * 添加成员
	 */
	public function add(){
		$this->display();
	}

	/**
	 * 处理添加
	 * @return [type] [description]
	 */
	public function handleAdd(){
		// print_r($_POST);

		// echo 1;
		// exit;
		$_POST['create_time'] = time();

		$res = M('lol')->add($_POST);

		if($res){
			$this->success('添加OK');
		}else{
			$this->error('失败');
		}
	}

	/**
	 * 修改
	 * @return [type] [description]
	 */
	public function edit(){

	}

	/**
	 * 处理修改
	 * @return [type] [description]
	 */
	public function handleEdit(){
		print_r($_POST);
	}

	/**
	 * 处理删除
	 * @return [type] [description]
	 */
	public function handleDelete(){
		
		$id = (int)$_GET['id'];

		M('lol')->where('id='.$id)->delete();

		$this->success('删除成功');
	}
	/**
	 * 展示统计图
	 * @return [type] [description]
	 */
	public function show(){
		$list = M('lol')->order('combat DESC')->select();

		foreach ($list as $key => $value) {
			$account[] = "'".$value['account']."'"; 
		}
		$account = join($account,',');
		$this->assign('account',$account);

		foreach ($list as $key => $value) {
			$data[] = $value['combat'];
		}

		$this->assign('data',join($data,','));
		
		$this->display();
	}



}